package com.boc.ewr.cornJob;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.boc.ewr.business.entity.CaCusmCallOlfdbk;
import com.boc.ewr.business.service.ICaCusmCallOlfdbkService;
import com.boc.ewr.util.file.enumeration.CusmFdbkTagEnum;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.util.DateUtils;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * @author : Wzz
 * @create : 2023-04- 20- 15:23
 * @desc :智能催收-智能催收待核实情况反馈-生成线上反馈的客户会话明细分类表
 */
@Slf4j
public class CusmCallOlfdbkGenJob implements Job {

    @Autowired
    private ICaCusmCallOlfdbkService caCusmCallOlfdbkService;

    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {

        log.info(" Job Execution key：" + jobExecutionContext.getJobDetail().getKey());
        log.info(String.format(" 生成线上反馈的客户会话明细分类表 CusmCallOlfdbkGenJob 时间:" + DateUtils.getTimestamp()));

        // 不会操作，U盾要重办 indexList
        List<String> tagList = new ArrayList<>();
        tagList.add(CusmFdbkTagEnum.UNABLEOOPERATE.getIndex());
        tagList.add(CusmFdbkTagEnum.REPROCESSING.getIndex());

        // 设置发送时间，视为发送的标志
        List<CaCusmCallOlfdbk> caCusmCallOlfdbkList = caCusmCallOlfdbkService.list(
                new LambdaQueryWrapper<CaCusmCallOlfdbk>()
                        .in(CaCusmCallOlfdbk::getCusmFdbkTag, tagList)
        );
        caCusmCallOlfdbkList
                .stream()
                .forEach(c -> c.setSendTime(new Date()));

        caCusmCallOlfdbkService.updateBatchById(caCusmCallOlfdbkList);

        // todo 消息推送

    }
}
